﻿<%@ Page Language="C#" MasterPageFile="~/TeamManager.Master" AutoEventWireup="true" CodeBehind="UserManagement.aspx.cs" Inherits="MonitoringServer.UserManagement" Title="User management" %>
  
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="BodyContent" ContentPlaceHolderID="BodyContentPlaceHolder" runat="server">
        <div >
            <table style="font-weight: normal; font-size: 12px; font-family: Arial" border="0" cellpadding=1 cellspacing=2 bgcolor="white" width="100%">
                <tr>
                    <td align="center" >
                    <b>List of the site users</b><br /><br />
                        <asp:GridView ID="GridViewMemberUser" runat="server" OnSelectedIndexChanged="GridViewMembershipUser_SelectedIndexChanged"
                            OnRowDeleted="GridViewMembership_RowDeleted" AllowPaging="True" AutoGenerateColumns="False"
                            DataKeyNames="UserName" DataSourceID="ObjectDataSourceMembershipUser" 
                        AllowSorting="True" CellPadding="1" Font-Size="X-Small" Width="95%" 
                        ForeColor="#333333" GridLines="None" BorderColor="White" Height="151px">
                            <Columns>
                                <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" ShowSelectButton="True" />
                                <asp:BoundField DataField="UserName" HeaderText="UserName" ReadOnly="True" SortExpression="UserName" />
                                <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                                
                                <asp:BoundField DataField="PasswordQuestion" HeaderText="PasswordQuestion" ReadOnly="True"
                                    SortExpression="PasswordQuestion" />
  
                                <asp:BoundField DataField="Comment" HeaderText="Comment" SortExpression="Comment" />
                                
                                <asp:BoundField DataField="CreationDate" HeaderText="CreationDate" ReadOnly="True"
                                    SortExpression="CreationDate" />
                                <asp:CheckBoxField DataField="IsApproved" HeaderText="IsApproved" SortExpression="IsApproved" />
                                <asp:BoundField DataField="LastLockoutDate" Visible="False" HeaderText="LastLockoutDate" ReadOnly="True"
                                    SortExpression="LastLockoutDate" />
                                <asp:BoundField DataField="LastLoginDate" HeaderText="LastLoginDate" SortExpression="LastLoginDate" />
                                <asp:CheckBoxField DataField="IsOnline" Visible="False" HeaderText="IsOnline" ReadOnly="True" SortExpression="IsOnline" />
                                <asp:CheckBoxField DataField="IsLockedOut" HeaderText="IsLockedOut" ReadOnly="True"
                                    SortExpression="IsLockedOut" Visible="False" />
                                <asp:BoundField DataField="LastActivityDate" HeaderText="LastActivityDate" SortExpression="LastActivityDate" Visible="False" />
                                <asp:BoundField DataField="LastPasswordChangedDate" HeaderText="LastPasswordChangedDate" Visible="False"
                                    ReadOnly="True" SortExpression="LastPasswordChangedDate" />
                                
                                <asp:BoundField DataField="ProviderName" HeaderText="ProviderName" ReadOnly="True" Visible="False"
                                    SortExpression="ProviderName" />
                            </Columns>
                            <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                            <RowStyle BackColor="#EFF3FB" />
                            <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                            <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
                            <HeaderStyle BackColor="#507CD1" Font-Bold="False" ForeColor="White" />
                            <EditRowStyle BackColor="#2461BF" />
                            <AlternatingRowStyle BackColor="White" />
                        </asp:GridView>
                        <asp:ObjectDataSource ID="ObjectDataSourceMembershipUser" runat="server" DeleteMethod="Delete"
                            SelectMethod="GetMembers"
                            TypeName="MembershipUtilities.MembershipUserODS" UpdateMethod="Update"
                            SortParameterName="SortData" >
                            <DeleteParameters>
                                <asp:Parameter Name="UserName" Type="String" />
                            </DeleteParameters>
                            <UpdateParameters>
                                <asp:Parameter Name="email" Type="String" />
                                <asp:Parameter Name="isApproved" Type="Boolean" />
                                <asp:Parameter Name="comment" Type="String" />
                                <asp:Parameter Name="lastActivityDate" Type="DateTime" />
                                <asp:Parameter Name="lastLoginDate" Type="DateTime" />
                            </UpdateParameters>
                            <SelectParameters>
                                <asp:Parameter Name="sortData" Type="String" />
                            </SelectParameters>
                            <InsertParameters>
                                <asp:Parameter Name="userName" Type="String" />
                                <asp:Parameter Name="isApproved" Type="Boolean" />
                                <asp:Parameter Name="comment" Type="String" />
                                <asp:Parameter Name="lastLockoutDate" Type="DateTime" />
                                <asp:Parameter Name="creationDate" Type="DateTime" />
                                <asp:Parameter Name="email" Type="String" />
                                <asp:Parameter Name="lastActivityDate" Type="DateTime" />
                                <asp:Parameter Name="providerName" Type="String" />
                                <asp:Parameter Name="isLockedOut" Type="Boolean" />
                                <asp:Parameter Name="lastLoginDate" Type="DateTime" />
                                <asp:Parameter Name="isOnline" Type="Boolean" />
                                <asp:Parameter Name="passwordQuestion" Type="String" />
                                <asp:Parameter Name="lastPasswordChangedDate" Type="DateTime" />
                                <asp:Parameter Name="password" Type="String" />
                                <asp:Parameter Name="passwordAnswer" Type="String" />
                            </InsertParameters>
                        </asp:ObjectDataSource><br /><br />
                    </td>
                </tr>
            </table>
            <table style="font-weight: normal; font-size: 12px; font-family: Arial" bgcolor="white" width="100%" border=0 cellpadding=1 cellspacing=2>
                <tr valign="top">
                    <td  align="center"  width=30%>
                    <b>Management of roles</b><br /><br />
                         <asp:GridView ID="GridViewRole" runat="server" AutoGenerateColumns="False" DataSourceID="ObjectDataSourceRoleObject"
                            DataKeyNames="RoleName" CellPadding="3" CellSpacing="3" AllowPaging="True" HorizontalAlign="Center" Width="100%">
                            <Columns>
                                <asp:CommandField ShowDeleteButton="True" DeleteText="Delete Role" />
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <asp:Button ID="Button1" runat="server" CausesValidation="false" Width="250px" OnClick="ToggleInRole_Click"
                                            Text='<%# ShowInRoleStatus( (string) Eval("UserName"),(string) Eval("RoleName")) %>' />
                                    </ItemTemplate>
                                    <ItemStyle HorizontalAlign="Left" />
                                    <HeaderTemplate>
                                        Status of roles for selected user
                                    </HeaderTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="NumberOfUsersInRole" HeaderText="Number Of Users In Role"
                                    SortExpression="NumberOfUsersInRole" />
                                
                                <asp:BoundField DataField="RoleName" ReadOnly="True" Visible="False" HeaderText="RoleName"
                                    SortExpression="RoleName" />
                                <asp:CheckBoxField DataField="UserInRole" HeaderText="UserInRole" Visible="False"
                                    SortExpression="UserInRole" />
                            </Columns>
                        </asp:GridView>
                        <asp:CheckBox ID="CheckBoxShowRolesAssigned" runat="server" AutoPostBack="True" Text="Show Roles Assigned Only" />
                    </td>
                    <td  align="center"  width=30%>
                    <b>Creator of new role</b><br /><br />
                        <asp:TextBox ID="TextBoxCreateNewRole" runat="server"></asp:TextBox><br /><br />
                        <asp:Button ID="ButtonCreateNewRole" runat="server" OnClick="ButtonCreateNewRole_Click"
                            Text="Create New Role" /><br />
                    </td>
                    <td  align="center" width=40%>
                    <b>Creator of new user</b><br />
                      <asp:CreateUserWizard ID="CreateUserWizard1" runat="server">
                        <WizardSteps>
                          <asp:CreateUserWizardStep runat="server" />
                          <asp:CompleteWizardStep runat="server" />
                        </WizardSteps>
                      </asp:CreateUserWizard>
                      <br />
                
                    </td>
                </tr>
            </table>
            <br />
             
            <asp:ObjectDataSource ID="ObjectDataSourceRoleObject" runat="server" SelectMethod="GetRoles"
                TypeName="MembershipUtilities.RoleDataObject" InsertMethod="Insert" DeleteMethod="Delete"  >
                <SelectParameters>
                    <asp:ControlParameter ControlID="GridViewMemberUser" Name="UserName" PropertyName="SelectedValue"
                        Type="String" />
                    <asp:ControlParameter ControlID="CheckBoxShowRolesAssigned" Name="ShowOnlyAssignedRolls"
                        PropertyName="Checked" Type="Boolean" />
                </SelectParameters>
                <InsertParameters>
                    <asp:Parameter Name="RoleName" Type="String" />
                </InsertParameters>
                <DeleteParameters>
                    <asp:Parameter Name="RoleName" Type="String" />
                </DeleteParameters>
            </asp:ObjectDataSource>
        </div>
  </asp:Content>
